﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Server.Model;
using System.Runtime.Serialization;

namespace Server.Service.Model
{
    [DataContract]
    public class WCFUser
    {
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public string AddressLine1 { get; set; }
        [DataMember]
        public string AddressLine2 { get; set; }
        [DataMember]
        public string Phone { get; set; }
        [DataMember]
        public string Email { get; set; }
        [DataMember]
        public string Password { get; set; }
        [DataMember]
        public bool Admin { get; set; }

        [DataMember]
        public WCFZipCodeCity ZipCodeCity { get; set; }
        [DataMember]
        public List<WCFCar> Cars { get; set; }
        [DataMember]
        public List<WCFReservation> Reservations { get; set; }

        public WCFUser(User user)
        {
            this.Id = user.Id;
            this.Name = user.Name;
            this.AddressLine1 = user.AddressLine1;
            this.AddressLine2 = user.AddressLine2;
            this.Phone = user.Phone;
            this.Email = user.Email;
            this.Password = user.Password;
            this.Admin = user.Admin;

            //Is loaded because of BCNF.
            this.ZipCodeCity = new WCFZipCodeCity() { City = user.ZipCodeCity.City, ZipCode = user.ZipCodeCity.ZipCode };

            Cars = new List<WCFCar>();
            Reservations = new List<WCFReservation>();
            
        }
    }

}
